import requests

# 访问百度
response = requests.get('http://www.baidu.com')
# 获取状态码
print('状态码:', response.status_code)
# 获取url
print('url', response.url)
# 字符编码
print('设置字符编码前', response.encoding)
# response.encoding = 'utf-8'
print('设置字符编码后', response.encoding)
# 头数据
print('所有头数据', response.headers)
print('Content-type数据', response.headers.get('Content-Type'))
# cookie
print('所有cookie', response.cookies)
print('制定cookie', response.cookies.get('BDORZ'))
# 文本内容
print('文本', response.text)
# 字节内容
print('字节', response.content)
print('字节设置utf-8', response.content.decode('utf-8'))
print(response.encoding)